package com.example.friend.controller.user;

import com.example.common.core.Controller.BaseController;
import com.example.common.core.constants.HttpConstants;
import com.example.common.core.domin.R;
import com.example.common.core.domin.TableDataInfo;
import com.example.friend.aspect.CheckUserStatus;
import com.example.friend.domain.exam.dto.ExamDTO;

import com.example.friend.domain.exam.dto.ExamQueryDTO;
import com.example.friend.service.user.impl.UserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {

    @Autowired
    private UserExamService userExamService;

    //竞赛报名
    //接口地址: /user/exam/enter
    @CheckUserStatus
    @PostMapping("/enter")
    public R<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token, @RequestBody ExamDTO examDTO) {
        return toR(userExamService.enter(token,examDTO.getExamId()));
    }

    //我的竞赛
    //接口地址: /user/exam/list
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO) {
        return userExamService.list(examQueryDTO);
    }
}
